package com.example.administrator.myapplication;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

public class OrderDetialListAdapter extends BaseAdapter {
    Context context;

    public OrderDetialListAdapter(Context order){
        this.context=order;


    }
    private ArrayList<OrderList> data = new ArrayList<>();

    public void setData(ArrayList<OrderList> lists) {



        data.addAll(lists);
        notifyDataSetChanged();

    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView==null){
            viewHolder=new ViewHolder();
            LayoutInflater layoutInflater=LayoutInflater.from(context);
            convertView=layoutInflater.inflate(R.layout.orderdetialitem,null);
            viewHolder.sku_name=convertView.findViewById(R.id.sku_name);
            viewHolder.cups=convertView.findViewById(R.id.cups);
            viewHolder.cups_number=convertView.findViewById(R.id.total_number);
            viewHolder.single_price=convertView.findViewById(R.id.singler_price);
            convertView.setTag(viewHolder);


        }
        else {
            viewHolder= (ViewHolder) convertView.getTag();
        }

        viewHolder.sku_name.setText(this.data.get(position).sku_name);
        viewHolder.single_price.setText("¥"+this.data.get(position).total_price1);
        viewHolder.cups_number.setText("*"+this.data.get(position).quantity);
        viewHolder.cups.setText(this.data.get(position).cup_type);
        Log.i("23123","(((((((((((((((((________________"+this.data.get(position).quantity);
        return convertView;
    }
    public class ViewHolder{

        TextView sku_name,cups,cups_number,single_price;


    }
}
